import {deleteAction, getAction, postAction, downFile, getFileAccessHttpUrl} from '@/api/request'

export const application12 = {

    data() {
        return {
            url: {
                tab12Infor: "/api/ac/subsistence/ss02017Service/getApproveTab12Info",
                tab12Submit: "/api/ac/subsistence/ss02017Service/updateTab12AdajustSubmit",
                getMemberList: "/api/ac/subsistence/ss12001ChangeService/getMemberList"
            },
            memberList: [],
            Loading: false,
            familyInfo: {},
            disabled: true,
            information: "",
            memberInformation: "",
            checkAgainDetail:"",
            ruleValidate: {
                ssca0044: [
                    {required: true, message: '家庭月基础收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0045: [
                    {required: true, message: '家庭月赡抚养费金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0046: [
                    {required: true, message: '家庭月财产收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0047: [
                    {required: true, message: '家庭月基础支出金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0049: [
                    {required: true, message: '家庭月总收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0051: [
                    {required: true, message: '家庭人口数不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0042: [
                    {required: true, message: '保障标准不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0052: [
                    {required: true, message: '保障人口数不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0025: [
                    {required: true, message: '分类救助上浮总金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0004: [
                    {required: true, message: '差额保障金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0026: [
                    {required: true, message: '总保障金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0065: [
                    {required: true, message: '高龄补贴总金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0013: [
                    {required: true, message: '请选择致贫原因！', trigger: 'change'}
                ],
                ssca0009: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'change'}
                ],
                ssca0082: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'change'}
                ],
                ssca0010: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0083: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0011: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0089: [
                    {required: true, message: '请选择是否入户调查、民主评议、审批公示！', trigger: 'blur'}
                ],
                ssca0090: [
                    {required: true, message: '请选择是否进行经济核查！', trigger: 'change'}
                ],
                yjab0009:[
                    {required: true, message: '预警处置原因不能为空！', trigger: 'blur'}
                ],
                yjab0008: [
                    {required: true, message: '处置时间不能为空！', trigger: 'change', pattern: /.+/}
                ],
            },
            ss02017Id:"",
            yjab0015:""

        }
    },
    methods: {
        //提交申请
        prevStep() {
            this.$emit('prevStep')
        },
        nextStep() {
            let busmodal=this.$parent.familyInfo.busmodal;
            let ssca0090=this.formValidate.ssca0090;
            let ssca0002=this.formValidate.ssca0002;
            //非建档立卡、受理调整阶段、受理时不发起经济核查、有人员变化情况，首次在受理调整保存时提示强制经济核查
            if (ssca0002!='203'&&ssca0090 == '0'&&busmodal== '0'&&this.checkAgainDetail) {
                this.$Modal.confirm({
                    title: this.checkAgainDetail,
                    onOk: () => {
                        this.tab12Submit();
                        this.$set(this.formValidate,"ssca0090","1");
                    }
                })
            } else {
                this.tab12Submit();
            }
        },
        printSs00011() {
            this.$refs.printModal.edit(this.$parent.familyInfo.ss12001Id);
        },
        tab12Submit() {
            this.Loading = true;
            var that = this;
            this.$refs['formValidate'].validate((valid) => {
                if (valid) {
                    postAction(that.url.tab12Submit, this.formValidate).then((res) => {
                        if (res.data.errcode == 0) {
                            that.$Message.success("保存成功！");
                            that.$emit('finish');
                        } else {
                            that.$Message.error(res.data.errmsg);
                        }
                    }).finally(() => {
                        that.Loading = false;
                    });
                } else {
                    that.Loading = false;
                }
            })
        },
        getFamilyInfor() {
            this.familyInfo = this.$parent.familyInfo;
        },
        getTab12Infor() {
            var that = this;
            postAction(that.url.tab12Infor, {
                ss12001Id: this.$parent.familyInfo.ss12001Id,
                type: 's17'
                // oldSs12001Id: this.$parent.familyInfo.oldSs12001Id
            }).then((res) => {
                if (res.data.errcode == 0) {
                    console.log(res.data.data)
                    that.formValidate = res.data.data.ss12001;
                    that.information = res.data.data.information;
                    that.memberInformation = res.data.data.memberInformation;
                    that.checkAgainDetail = res.data.data.checkAgainDetail;

                    that.label=that.formValidate.ssca0002=='203'?'是否入户调查：':'是否入户调查、民主评议、审批公示:';
                    if (that.formValidate.ssca0002 == '100' || that.formValidate.ssca0002 == '200' || that.formValidate.ssca0002 == '102' || that.formValidate.ssca0002 == '202') {
                        that.text = "总保障金额=差额保障金额+分类救助上浮总金额，不包括高龄补贴总金额";
                    } else {
                        that.text = "总保障金额=保障人口数*保障标准，不包括高龄补贴总金额";
                    }

                    //预警处置信息
                    if (that.formValidate.ssca0102) {
                        that.formValidate.ssca0102 = this.DateFormat(that.formValidate.ssca0102, 'YYYY-MM-DD');
                    }
                    if (that.formValidate.ssca0104) {
                        that.formValidate.ssca0104 = this.DateFormat(that.formValidate.ssca0104, 'YYYY-MM-DD');
                    }
                    //本户其他预警数据数量
                    that.ss02017Id=res.data.data.ss02017Id;
                    that.yjab0015=that.formValidate.ssca0107;
                    that.otherWarnCount=res.data.data.otherWarnCount;
                    that.$set(that.formValidate,'ss02017Id',that.ss02017Id);
                } else {
                    that.$Message.error(res.data.errmsg);
                }
            }).finally(() => {
                that.Loading = false;
            });
        },
        showOthers(){
            this.$refs.otherWarnModal.edit(this.ss02017Id,this.yjab0015);
        }
    }
}
